#pragma once
#include "stdafx.h"
#include "AStarSimpleGoal.h"
#include "util.h"
#pragma warning(disable:4800)
namespace Core
{
	AStarSimpleGoal::AStarSimpleGoal(SimpleMap::LogicPart & map,Position& start,Position& destination)
:mMap(map),mStart(start),mDestination(destination)
{
}

AStarSimpleGoal::~AStarSimpleGoal(void)
{
	
}
bool AStarSimpleGoal::TailIsOpen(const Position& pos)
{
	if(pos.x<0||pos.x>=mMap.GetMapSize().width||pos.y<0||pos.y>=mMap.GetMapSize().height) return false;
	return mMap.GetInfo(pos).info==SimpleMap::MapInfo::PASS;
}
double AStarSimpleGoal::DistanceToGoal(const Position& pos) 
{
	return abs(pos.x-mDestination.x)+abs(pos.y-mDestination.y);
}
double AStarSimpleGoal::GetTileCost(const Position& pos) 
{
	return 5*(!(bool)mMap.GetInfo(pos).info);
}
Position& AStarSimpleGoal::GetStart()
{
	return mStart;
}
Position& AStarSimpleGoal::GetDestination()
{
	return mDestination;
}
}